﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;


namespace Emotive.ProjectUI.Test
{
    /// <summary>
    /// Summary description for CodedUITest1
    /// </summary>
    [CodedUITest]
    public class ProjectUI
    {
        public ProjectUI()
        {
        }

        [TestMethod]
        public void OpenProjectSol()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.StartDesigner();
            this.UIMap.LoadProjectSol();
        }

        [TestMethod]
        public void Proj_Add()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddNewProj1();
            this.UIMap.CheckNewProj1();
            this.UIMap.CheckNewProj1ProcMain();
            this.UIMap.AddNewProj2();
            this.UIMap.CheckNewProj2();
            this.UIMap.CheckNewProj2ProcMain();
        }

        [TestMethod]
        public void Proj_Rename()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.RenameNewProj1();
            this.UIMap.CheckProj1();
        }

        [TestMethod]
        public void Proj_Deploy()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.DeployProj1();
            this.UIMap.CheckProj1msi();
            this.UIMap.CloseDeploymentWindow();
        }

        [TestMethod]
        public void Proj_ExportPdx()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.ExportProj1Pdx();
        }

        [TestMethod]
        public void Proj_AddPdx()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddProj1pdx();
            this.UIMap.ExpandProj1References();

        }

        [TestMethod]
        public void Proj_Reference()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463

            //this.UIMap.ReferenceNewProj2();

        }

        [TestMethod]
        public void Proj_AddExisting()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463

            this.UIMap.AddExistingProjectValidation();
            this.UIMap.CheckProjectValidation();
        }

        [TestMethod]
        public void Proj_Validate()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.ValidateProjectValidation();
            this.UIMap.CheckErrorNum();
            this.UIMap.CheckWarningNum();          
        }

        [TestMethod]
        public void Proj_AddFromPdx()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddProjectPdxSample();
            this.UIMap.CheckPdxSampleProj();
        }

        [TestMethod]
        public void Proj_AddSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddProj1SameName();
            this.UIMap.CheckSameProjNameError();
            this.UIMap.ClickOKSameProjNameError();
            this.UIMap.ClickCancelCreateProj();
            this.UIMap.AddProj1_A();
            this.UIMap.CheckSameProjNameError();
            this.UIMap.ClickOKSameProjNameError();
            this.UIMap.ClickCancelCreateProj_A();
        }

        [TestMethod]
        public void Proj_AddInvalidName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddWrongFormatProjName();
            this.UIMap.CheckWrongFormatProjName();
            this.UIMap.ClickOKWrongFormatProjName();
            this.UIMap.ClickCancelCreateProj();
            this.UIMap.AddWrongFormatProjName_A();
            this.UIMap.CheckWrongFormatProjName();
            this.UIMap.ClickOKSameProjNameError();
            this.UIMap.ClickCancelCreateProj_A();
        }

        [TestMethod]
        public void Proj_AddExistingSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddExistingProj1();
            this.UIMap.CheckWarningSameProjName();
            this.UIMap.ClickOKCopyOfProj1();
            this.UIMap.CheckCopyOfProj1();
        }

        [TestMethod]
        public void Proj_Delete()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.DeleteCopyOfProj1();
            this.UIMap.DeleteNewProj2();
        }

        [TestMethod]
        public void Proj_AddFromPdxSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddProjectProj1pdx();
            this.UIMap.CheckWarningSameProjName();
            this.UIMap.ClickOKCopyOfProj1();
            this.UIMap.CheckCopyOfProj1();
        }


        [TestMethod]
        public void Proj_RenameSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463

            this.UIMap.RenameCopyOfProj1();
            this.UIMap.CheckSameProjNameError();
            this.UIMap.ClickOKSameProjNameError();
            this.UIMap.RenameCopyOfProj1_A();
            this.UIMap.CheckNewProj2();
        }

        #region Additional test attributes

        // You can use the following additional attributes as you write your tests:

        ////Use TestInitialize to run code before running each test 
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
        //}

        ////Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
        //}

        #endregion

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        private TestContext testContextInstance;

        public UIMap UIMap
        {
            get
            {
                if ((this.map == null))
                {
                    this.map = new UIMap();
                }

                return this.map;
            }
        }

        private UIMap map;
    }
}
